package com.Jano.service.Impl;

import com.Jano.dao.ChoiceDao;
import com.Jano.dao.Impl.ChoiceDaoImpl;
import com.Jano.entity.Choice;
import com.Jano.exception.BusinessException;
import com.Jano.service.ChoiceService;
import org.apache.commons.lang3.StringUtils;

import java.util.List;

/**
 * description: ChoiceServiceImpl <br>
 * date: 2022/6/6 7:35 PM <br>
 * author: zoumaoji <br>
 * version: 1.0 <br>
 */
public class ChoiceServiceImpl extends AbstractBaseServiceImpl implements ChoiceService {
    ChoiceDao choiceDao =new ChoiceDaoImpl();

    @Override
    public void createChoice(int questionId, String content, String ord) {
        if (StringUtils.isBlank(content)) {
            throw new BusinessException("答案内容不能为空");
        }
        if (StringUtils.isBlank(ord)) {
            throw new BusinessException("选项编号不能为空");
        }
        choiceDao.createChoice(questionId,content,ord);
    }

    @Override
    public List<Choice> getAllChoicesByQuestionId(int questionId) {
        return choiceDao.selectChoicesByQuestionId(questionId);
    }
}
